Skip to content

Fix rand scalar context for Randomize#688

Merged
fglock merged 1 commit intomasterfrom
fix/jcpan-randomize
May 8, 2026
Merged

Fix rand scalar context for Randomize#688
fglock merged 1 commit intomasterfrom
fix/jcpan-randomize

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented May 8, 2026

Summary

  • Compile bytecode rand operands in scalar context so rand @$array_ref uses the array length
  • Scalarize the interpreter RAND opcode input defensively for eval-generated bytecode
  • Add regression coverage for the Randomize eval-generated sub failure path

Tests

  • make
  • timeout 60 ./jperl src/test/resources/unit/rand_scalar_context.t
  • timeout 600 ./jcpan -t Randomize

Note: Randomize still prints legacy not ok 46-50 lines from raw Data::Dumper hash-key ordering comparisons, but its CPAN make test exits OK. Native Perl shows the same brittle ordering issue.

Compile rand operands in scalar context so array dereferences like rand @$array produce the array length instead of a RuntimeArray value. Also scalarize the RAND opcode input defensively for eval-generated interpreter bytecode.

Add regression coverage for eval-generated rand array dereferences, matching the Randomize failure path.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
@fglock fglock merged commit 1d17916 into master May 8, 2026
2 checks passed
@fglock fglock deleted the fix/jcpan-randomize branch May 8, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant